package com.stub.view;

import com.common.bean.StubRange;
import com.common.util.SystemHWUtil;
import oa.bean.stub.OneStub;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * Created by whuanghkl on 17/5/7.
 */
public class SearchViewModel {
    public SearchViewModel(StubRange stubRange){
        this.attributeName=stubRange.getAttributeName();
        List<String> stubStrs=stubRange.getStubs();
        int size=stubStrs.size();
        Map< Integer,String> indexAttributeValMap= SystemHWUtil.reverseMap(stubRange.getAttributeValIndexMap());
        this.selectedIndex=stubRange.getSelectedIndex();
        for (int i=0;i<size;i++){
            String stub=stubStrs.get(i);
            OneStub oneStub=new OneStub();
            oneStub.setStub(stub);
            oneStub.setAttributeVal(indexAttributeValMap.get(i));
            this.stubs.add(oneStub);
        }
    }
    private List<OneStub>stubs=new ArrayList<OneStub>();
    /***
     * 请求参数名称<br />
     * String parameterVal=request.getParameter(attributeName);
     */
    private String attributeName;
    /***
     * 当前的stub,序号从零开始
     */
    private int selectedIndex;

    public List<OneStub> getStubs() {
        return stubs;
    }

    public void setStubs(List<OneStub> stubs) {
        this.stubs = stubs;
    }

    public String getAttributeName() {
        return attributeName;
    }

    public void setAttributeName(String attributeName) {
        this.attributeName = attributeName;
    }

    public int getSelectedIndex() {
        return selectedIndex;
    }

    public void setSelectedIndex(int selectedIndex) {
        this.selectedIndex = selectedIndex;
    }
}


